

<div style="margin: 30px;border:1px solid #ddd;padding:30px 20px;border-radius:5px;">
	<div class="row">
		<div class="col-sm-5 form-group">
			<label for="title" class="col-sm-2 control-label">标题</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" id="title"
					placeholder="请输入标题">
			</div>
		</div>
	</div>
	
	<div class="row">
		<div class="col-sm-5 form-group">
			<label for="desc" class="col-sm-2 control-label">描述</label>
			<div class="col-sm-10">
				<textarea type="text" class="form-control" id="desc"
					placeholder="请输入描述" rows="6"></textarea>
			</div>
		</div>
	</div>
	
	<div class="row">
		<div class="col-sm-5 form-group">
			<button id ="submit" type="submit" style="margin: 10px auto; display: block;"
	class="btn btn-primary">发布</button>
		</div>
	</div>
</div>

<script>
var _url="/user/newQuestionPost";
var is_send=false;
$(function(){
	$('#submit').click(function(){
		var _title=$("#title").val();
		var _desc=$("#desc").val();
		if(_title==''){
			swal("标题不能为空");
			return false;
		}
		
		if(_desc==''){
			swal("描述不能为空");
			return false;
		}
		//发送请求
			if (is_send == false) {
				$('#submit').val('正在提交');
				$.ajax({
					type: 'POST',
					url: _url,
					data: {
						'title': _title,
						'desc':_desc
					},
					dataType: 'json',
					success: function(data) {
						$('#submit').val('提交');
						swal(data.msg);
					},
					error: function(xhr, type) {
						$('#submit').val('提交');
						swal('网络不好');
					}
				});
			}
		
		});
});


</script>